package com.zbkj.crmeb.tools.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.tools.model.MoneyExchange;
import com.zbkj.crmeb.tools.service.MoneyExchangeService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 后台管理员表 前端控制器
 */
@RestController
@RequestMapping("api/admin/tools/exchange")
@Api(tags = "货币兑换汇率")
public class MoneyExchangeController {

	@Autowired
	private MoneyExchangeService moneyExchangeService;

	/**
	 * 更新实时汇率
	 * 
	 * @author Mr.Zhang
	 * @since 2020-04-13
	 */
	@ApiOperation(value = "更新汇率")
	@RequestMapping(value = "/update", method = RequestMethod.GET)
	@ResponseBody
	public CommonResult<String> update() {
		moneyExchangeService.syncMoneyExchangeData();
		return CommonResult.success("更新成功");
	}

	/**
	 * 获取实时汇率
	 * @author daigb
	 * @date:  2021-12-17 15:43
	 */
	@ApiOperation(value = "获取实时汇率")
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public CommonResult<List<MoneyExchange>> list() {
		return CommonResult.success(moneyExchangeService.list());
	}

}
